<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
        <title>Jalava : Web-based Diagram Editor</title>
        <script language="JavaScript" src="./js/Jalava.js"></script>
        <script language="JavaScript">
            var url = "http://marinoflow.appspot.com/nstr.txt";
            // initialise Jalava here
            function buttonClicked() {
                var value = 12;
                //      wave.getState().submitDelta({'count': value + 1});
            }

            function dodo(){
                objXml = new XMLHttpRequest();
                objXml.open("GET",url,false);
                objXml.send(null);
                str = objXml.responseText;
                confirm("ECCO " +str);
                Jalava.diagram.load(str);
            }
            
            function salva(str){
                //      var jsonString = Jalava.diagram.persist();
                //     confirm (jsonString);
                //        var comments = document.getElementById('comments');
                document.forms["forma"].elements['comments'].value = str;
                var aa = JSON.parse(str);
            }

            function stateUpdated() {

                //  Jalava.start(initJalava);
            }

            function pippo() {
                //   if (wave && wave.isInWaveContainer()) {
                //     wave.setStateCallback(stateUpdated);
                //}

                Jalava.addModule("FlowChartPaletteFactory");
                Jalava.addModule("FlowChartPropertyPage");
                Jalava.addModule("UrlGradientBlock");
                Jalava.start(initJalava);  // qui o dopo?
            }
            function initJalava(){
                Jalava.diagram = new Diagram(220,200, "550", "600");
                var palette = new Palette(new FlowChartPaletteFactory(), 0, 100, 200);
                palette.addItem("rect", "Processing",  Palette.DRAG_TOOL, "./img/rect.gif");
                palette.addItem("connection", "Connection",  Palette.CLICK_TOOL, "./img/line.gif");
                palette.addItem("diamond", "Decision", Palette.DRAG_TOOL, "./img/diamond.gif");
                palette.addItem("parallel", "Input/Output", Palette.DRAG_TOOL, "./img/parallel.gif");
                palette.addItem("ellipse", "Connection", Palette.DRAG_TOOL, "./img/ellipse.gif");
                palette.addItem("rounded", "Start/End", Palette.DRAG_TOOL, "./img/ellipse.gif");
                Jalava.propertyPage = new FlowChartPropertyPage(20, 240, 10);
                
            }
            // start Jalava

            Jalava.addModule("FlowChartPaletteFactory");
            Jalava.addModule("FlowChartPropertyPage");
            Jalava.addModule("UrlGradientBlock");
            Jalava.start(initJalava);
            //  gadgets.util.registerOnLoadHandler(pippo);
        </script>

    </head>
    <body>

        <FORM id="forma">
            <TEXTAREA NAME="comments" id="comments" COLS=40 ROWS=6></TEXTAREA>

            <input type=button value="Click Me!" id="butCount" onClick="buttonClicked()">

            <INPUT type="button" value="See JSon" name="button2" onClick=" var jsonString = Jalava.diagram.persist(); confirm (jsonString); salva(jsonString);">

            <INPUT type="button" value="load" name="button3" onClick="dodo();">
        </FORM>
    </body>
</html>